/**11 normal
 * 双向遍历
 */
/**
 *
 * @param {number[]} arr
 */
function maxBox(arr) {
  let maxSize = 0;
  let i = 0;
  let j = arr.length - 1;
  while (i < j) {
    const size = Math.min(arr[i], arr[j]) * (j - i);
    if (size > maxSize) {
      maxSize = size;
    }
    arr[i] >= arr[j] ? j-- : i++;
  }
  return maxSize;
}
console.log(maxBox([1, 8, 6, 2, 5, 4, 8, 3, 7]));
